def f(arr,ans,n):
    if ans<n:
        for i in range(1,n+1):
            if i not in arr:
                arr.append(i)
                f(arr,ans+1,n)
                arr.remove(i)
    else:
        for i in arr:
            print(i,end='')
        print()
n=eval(input())
arr=list()
for i in range(1,n+1):
    arr.append(i)
    f(arr,1,n)
    arr.remove(i)